<?php

use Xx2025\Kingdee\Erp\Client;

! defined('BASE_PATH') && define('BASE_PATH', __DIR__);
require BASE_PATH . '/vendor/autoload.php';




$apiUrl = '';
$appKey = '';
$sessionKey = '';
$secret = '';

Client::init($apiUrl, $appKey, $sessionKey, $secret);


//新增商品以及SKU
//$skuList[] = [
//    'sku_code'=>'T-1017-JPN001',
//    'sku_name'=>'日版1017-001',
//];
//$skuList[] = [
//    'sku_code'=>'T-1017-JPN002',
//    'sku_name'=>'日版1017-002',
//];
//$skuList[] = [
//    'sku_code'=>'T-1017-JPN003',
//    'sku_name'=>'日版1017-003',
//];
//$res = \Xx2025\Kingdee\Erp\Service\Goods::newGoodsAndSku('T-1017', '测试001', $skuList, 'CSSP', 0);
//var_dump($res->isSuccessful());



//更新商品SKU
//$skuList[] = [
//    'sku_code'=>'T-1017-JPN001',
//    'sku_name'=>'日版1017-001',
//];
//$skuList[] = [
//    'sku_code'=>'T-1017-JPN002',
//    'sku_name'=>'日版1017-002',
//];
//
//$skuList[] = [
//    'sku_code'=>'T-1017-JPN003',
//    'sku_name'=>'日版1017-003',
//];
//
//$res = \Xx2025\Kingdee\Erp\Service\Goods::updateGoodsAndSku('T-1017', '测试001', $skuList, 'CSSP', 0);
//
//var_dump($res->isSuccessful());


//查询商品SKU列表
//$res = \Xx2025\Kingdee\Erp\Service\Goods::queryGoodsByCode('T-1017');
//var_dump($res->isSuccessful());
//var_dump($res->getSkuList());
//var_dump($res->getErrMsg());


//新增采购入库单
//$detail = [
//    'item_code'=>'T-1017',
//    'sku_code'=>'T-1017-JPN002',
//    'qty'=>'1',
//];
//if(isset($uniqueCode)){
//    $detail['uniqueCode'] = $uniqueCode;
//}
//$res = \Xx2025\Kingdee\Erp\Service\Goods::newGoodsPurchase('202500001', 'T-001', 'CSSP', [$detail]);


//采购入库单查询
$response = \Xx2025\Kingdee\Erp\Service\Goods::queryGoodsPurchaseOrder('PAO845726788043');
var_dump($response->getPurchaseState());

//新增供应商
$response = \Xx2025\Kingdee\Erp\Service\Supplier::newSupplier('001', '001号');
var_dump($response->isSuccessful());


//查询供应商代码列表
$response = \Xx2025\Kingdee\Erp\Service\Supplier::getSupplierCodeList('001');
var_dump($response->getSupplierCodeList());


//新增发货订单
$detailList[] = [
    'item_code'=>'001',
    'sku_code'=>'001',
    'price'=>'1.0',
    'qty'=>1,
];
$response = \Xx2025\Kingdee\Erp\Service\Order::newShippingOrder(
    '001', '001', '202500001', 'CSSP', $detailList, '张3', '188888888888', '广东省', '深圳市', '南山区', '');
var_dump($response->isSuccessful());
var_dump($response->getBillCode());


//查询发货单物流
$response = \Xx2025\Kingdee\Erp\Service\Order::getLogisticsInfo('202500001');
var_dump($response->isSuccessful());
var_dump($response->getExpressName());
var_dump($response->getDeliveryAt());
var_dump($response->getDeliveryState());

//新增退货订单
$response = \Xx2025\Kingdee\Erp\Service\Order::newOrderReturn('', '', '', '', '', '', '', []);
var_dump($response->isSuccessful());
var_dump($response->getBillCode());


//查询退货订单
$response = \Xx2025\Kingdee\Erp\Service\Order::queryOrderReturn('');
var_dump($response->isSuccessful());
var_dump($response->getErpReceiveDate());
var_dump($response->getReturnState());


//取消发货订单
$response = \Xx2025\Kingdee\Erp\Service\Order::cancelOrder('');
var_dump($response->isSuccessful());
